<template>
  <div class="roots">
    <div id="help_bar" class="help_bar" :class="helpBarFixed ? 'isFixed':''">
      <ul>
        <li class="title">
          <span>需要帮助？</span>
        </li>
        <li :class="pageSwitch? 'btn pageSwitch':'btn'">
          <router-link to="/index/help/question"><span @click="pageSwitch = true">常见问题</span></router-link>
        </li>
        <li :class="pageSwitch? 'btn':'btn pageSwitch'">
          <router-link to="/index/help/call" @click="pageSwitch = false"><span @click="pageSwitch = false">联系我们</span></router-link>
        </li>
      </ul>
    </div>
    <div class="main">
      <router-view/>
    </div>
  </div>
</template>

<script>
  import HeaderNavigation from '../currency/top/HeaderNavigation'
  import TopBanner from '../currency/top/TopBanner'
  import HeaderTools from '../currency/top/HeaderTools'

  export default {
    name: "Help",
    components: {
      HeaderNavigation,
      TopBanner,
      HeaderTools,
    },
    data() {
      return {
        helpBarFixed: false,
        pageSwitch:true,
      }
    },
    methods: {

      handleScroll() {
        var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;

        var offsetTop = document.querySelector('#help_bar').offsetTop;
        this.helpBarFixed = scrollTop > offsetTop;
      },

    },
    mounted() {
      window.addEventListener('scroll', this.handleScroll)
    },
    destroyed() {
      window.removeEventListener('scroll', this.handleScroll)
    },
  }
</script>
<style scoped>
  .help_bar {
    height: 80px;
    width: 100%;
    box-sizing: border-box;
    padding: 0 43px;
    box-shadow: 0 1px 0 0 #eae8e4;
    background-color: white;
  }

  .isFixed {
    position: fixed;
    top: 0;
    z-index: 999;
  }
  .help_bar{
    height: 80px;
  }
  .help_bar li {
    float: left;
    height: 80px;
    line-height: 80px;
  }

  .title, .btn {
    border-right: 1px solid #eae8e4;
  }

  .btn:hover {
    box-shadow: inset 0 -1px 0 0 black;
  }

  .title {
    width: 900px;
    font-size: 1.125rem;
    font-weight: 700;
  }

  .btn {
    width: 136px;
    line-height: 80px;
    text-align: center;
  }

  .pageSwitch{
    box-shadow: inset 0 -1px 0 0 black;
  }
  .main {
    background-color: #f6f5f3;
    position: relative;
    box-sizing: border-box;
    padding: 55px 80px 60px 60px;
  }

</style>
